home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / X11 / XLoadFont.z / XLoadFont
Encoding:
Text File  |  2002-10-03  |  18.0 KB  |  397 lines

  1.  
  2.  
  3.  
  4.      XXXXLLLLooooaaaaddddFFFFoooonnnntttt((((3333XXXX11111111))))    XXXX VVVVeeeerrrrssssiiiioooonnnn 11111111 ((((RRRReeeelllleeeeaaaasssseeee 6666....6666))))     XXXXLLLLooooaaaaddddFFFFoooonnnntttt((((3333XXXX11111111))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.           XLoadFont, XQueryFont, XLoadQueryFont, XFreeFont,
  10.           XGetFontProperty, XUnloadFont, XCharStruct, XFontProp,
  11.           XChar2b, XFontStruct - load or unload fonts and font metric
  12.           structures
  13.  
  14.      SSSSYYYYNNNNTTTTAAAAXXXX
  15.           Font XLoadFont(_d_i_s_p_l_a_y, _n_a_m_e)
  16.                 Display *_d_i_s_p_l_a_y;
  17.                 char *_n_a_m_e;
  18.  
  19.           XFontStruct *XQueryFont(_d_i_s_p_l_a_y, _f_o_n_t__I_D)
  20.                 Display *_d_i_s_p_l_a_y;
  21.                 XID _f_o_n_t__I_D;
  22.  
  23.           XFontStruct *XLoadQueryFont(_d_i_s_p_l_a_y, _n_a_m_e)
  24.                 Display *_d_i_s_p_l_a_y;
  25.                 char *_n_a_m_e;
  26.  
  27.           XFreeFont(_d_i_s_p_l_a_y, _f_o_n_t__s_t_r_u_c_t)
  28.                 Display *_d_i_s_p_l_a_y;
  29.                 XFontStruct *_f_o_n_t__s_t_r_u_c_t;
  30.  
  31.           Bool XGetFontProperty(_f_o_n_t__s_t_r_u_c_t, _a_t_o_m, _v_a_l_u_e__r_e_t_u_r_n)
  32.                 XFontStruct *_f_o_n_t__s_t_r_u_c_t;
  33.                 Atom _a_t_o_m;
  34.                 unsigned long *_v_a_l_u_e__r_e_t_u_r_n;
  35.  
  36.           XUnloadFont(_d_i_s_p_l_a_y, _f_o_n_t)
  37.                 Display *_d_i_s_p_l_a_y;
  38.                 Font _f_o_n_t;
  39.  
  40.      AAAARRRRGGGGUUUUMMMMEEEENNNNTTTTSSSS
  41.           _a_t_o_m      Specifies the atom for the property name you want
  42.                     returned.
  43.  
  44.           _d_i_s_p_l_a_y   Specifies the connection to the X server.
  45.  
  46.           _f_o_n_t      Specifies the font.
  47.  
  48.           _f_o_n_t__I_D   Specifies the font ID or the _G_C_o_n_t_e_x_t ID.
  49.  
  50.           _f_o_n_t__s_t_r_u_c_t
  51.                     Specifies the storage associated with the font.
  52.  
  53.           _g_c        Specifies the GC.
  54.  
  55.           _n_a_m_e      Specifies the name of the font, which is a null-
  56.                     terminated string.
  57.  
  58.           _v_a_l_u_e__r_e_t_u_r_n
  59.                     Returns the value of the font property.
  60.  
  61.  
  62.  
  63.      Page 1                                          (printed 10/3/02)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      XXXXLLLLooooaaaaddddFFFFoooonnnntttt((((3333XXXX11111111))))    XXXX VVVVeeeerrrrssssiiiioooonnnn 11111111 ((((RRRReeeelllleeeeaaaasssseeee 6666....6666))))     XXXXLLLLooooaaaaddddFFFFoooonnnntttt((((3333XXXX11111111))))
  71.  
  72.  
  73.  
  74.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  75.           The _X_L_o_a_d_F_o_n_t function loads the specified font and returns
  76.           its associated font ID.  If the font name is not in the Host
  77.           Portable Character Encoding, the result is implementation-
  78.           dependent.  Use of uppercase or lowercase does not matter.
  79.           When the characters ``?'' and ``*'' are used in a font name,
  80.           a pattern match is performed and any matching font is used.
  81.           In the pattern, the ``?'' character will match any single
  82.           character, and the ``*'' character will match any number of
  83.           characters.  A structured format for font names is specified
  84.           in the X Consortium standard _X _L_o_g_i_c_a_l _F_o_n_t _D_e_s_c_r_i_p_t_i_o_n
  85.           _C_o_n_v_e_n_t_i_o_n_s.  If _X_L_o_a_d_F_o_n_t was unsuccessful at loading the
  86.           specified font, a _B_a_d_N_a_m_e error results.  Fonts are not
  87.           associated with a particular screen and can be stored as a
  88.           component of any GC.  When the font is no longer needed,
  89.           call _X_U_n_l_o_a_d_F_o_n_t.
  90.  
  91.           _X_L_o_a_d_F_o_n_t can generate _B_a_d_A_l_l_o_c and _B_a_d_N_a_m_e errors.
  92.  
  93.           The _X_Q_u_e_r_y_F_o_n_t function returns a pointer to the _X_F_o_n_t_S_t_r_u_c_t
  94.           structure, which contains information associated with the
  95.           font.  You can query a font or the font stored in a GC.  The
  96.           font ID stored in the _X_F_o_n_t_S_t_r_u_c_t structure will be the
  97.           _G_C_o_n_t_e_x_t ID, and you need to be careful when using this ID
  98.           in other functions (see _X_G_C_o_n_t_e_x_t_F_r_o_m_G_C).  If the font does
  99.           not exist, _X_Q_u_e_r_y_F_o_n_t returns NULL.  To free this data, use
  100.           _X_F_r_e_e_F_o_n_t_I_n_f_o.
  101.  
  102.           _X_L_o_a_d_Q_u_e_r_y_F_o_n_t can generate a _B_a_d_A_l_l_o_c error.
  103.  
  104.           The _X_L_o_a_d_Q_u_e_r_y_F_o_n_t function provides the most common way for
  105.           accessing a font.  _X_L_o_a_d_Q_u_e_r_y_F_o_n_t both opens (loads) the
  106.           specified font and returns a pointer to the appropriate
  107.           _X_F_o_n_t_S_t_r_u_c_t structure.  If the font name is not in the Host
  108.           Portable Character Encoding, the result is implementation-
  109.           dependent.  If the font does not exist, _X_L_o_a_d_Q_u_e_r_y_F_o_n_t
  110.           returns NULL.
  111.  
  112.           The _X_F_r_e_e_F_o_n_t function deletes the association between the
  113.           font resource ID and the specified font and frees the
  114.           _X_F_o_n_t_S_t_r_u_c_t structure.  The font itself will be freed when
  115.           no other resource references it.  The data and the font
  116.           should not be referenced again.
  117.  
  118.           _X_F_r_e_e_F_o_n_t can generate a _B_a_d_F_o_n_t error.
  119.  
  120.           Given the atom for that property, the _X_G_e_t_F_o_n_t_P_r_o_p_e_r_t_y
  121.           function returns the value of the specified font property.
  122.           _X_G_e_t_F_o_n_t_P_r_o_p_e_r_t_y also returns _F_a_l_s_e if the property was not
  123.           defined or _T_r_u_e if it was defined.  A set of predefined
  124.           atoms exists for font properties, which can be found in
  125.           <_X_1_1/_X_a_t_o_m._h>.  This set contains the standard properties
  126.  
  127.  
  128.  
  129.      Page 2                                          (printed 10/3/02)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      XXXXLLLLooooaaaaddddFFFFoooonnnntttt((((3333XXXX11111111))))    XXXX VVVVeeeerrrrssssiiiioooonnnn 11111111 ((((RRRReeeelllleeeeaaaasssseeee 6666....6666))))     XXXXLLLLooooaaaaddddFFFFoooonnnntttt((((3333XXXX11111111))))
  137.  
  138.  
  139.  
  140.           associated with a font.  Although it is not guaranteed, it
  141.           is likely that the predefined font properties will be
  142.           present.
  143.  
  144.           The _X_U_n_l_o_a_d_F_o_n_t function deletes the association between the
  145.           font resource ID and the specified font.  The font itself
  146.           will be freed when no other resource references it.  The
  147.           font should not be referenced again.
  148.  
  149.           _X_U_n_l_o_a_d_F_o_n_t can generate a _B_a_d_F_o_n_t error.
  150.  
  151.      SSSSTTTTRRRRUUUUCCCCTTTTUUUURRRREEEESSSS
  152.           The _X_F_o_n_t_S_t_r_u_c_t structure contains all of the information
  153.           for the font and consists of the font-specific information
  154.           as well as a pointer to an array of _X_C_h_a_r_S_t_r_u_c_t structures
  155.           for the characters contained in the font.  The _X_F_o_n_t_S_t_r_u_c_t,
  156.           _X_F_o_n_t_P_r_o_p, and _X_C_h_a_r_S_t_r_u_c_t structures contain:
  157.  
  158.           typedef struct {
  159.                short lbearing;          /* origin to left edge of raster */
  160.                short rbearing;          /* origin to right edge of raster */
  161.                short width;             /* advance to next char's origin */
  162.                short ascent;            /* baseline to top edge of raster */
  163.                short descent;           /* baseline to bottom edge of raster */
  164.                unsigned short attributes;/* per char flags (not predefined) */
  165.           } XCharStruct;
  166.  
  167.           typedef struct {
  168.                Atom name;
  169.                unsigned long card32;
  170.           } XFontProp;
  171.  
  172.           typedef struct {              /* normal 16 bit characters are two bytes */
  173.               unsigned char byte1;
  174.               unsigned char byte2;
  175.           } XChar2b;
  176.  
  177.           typedef struct {
  178.                XExtData *ext_data;      /* hook for extension to hang data */
  179.                Font fid;                /* Font id for this font */
  180.                unsigned direction;      /* hint about the direction font is painted */
  181.                unsigned min_char_or_byte2;/* first character */
  182.                unsigned max_char_or_byte2;/* last character */
  183.                unsigned min_byte1;      /* first row that exists */
  184.                unsigned max_byte1;      /* last row that exists */
  185.                Bool all_chars_exist;    /* flag if all characters have nonzero size */
  186.                unsigned default_char;   /* char to print for undefined character */
  187.                int n_properties;        /* how many properties there are */
  188.                XFontProp *properties;   /* pointer to array of additional properties */
  189.                XCharStruct min_bounds;  /* minimum bounds over all existing char */
  190.                XCharStruct max_bounds;  /* maximum bounds over all existing char */
  191.                XCharStruct *per_char;   /* first_char to last_char information */
  192.  
  193.  
  194.  
  195.      Page 3                                          (printed 10/3/02)
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.      XXXXLLLLooooaaaaddddFFFFoooonnnntttt((((3333XXXX11111111))))    XXXX VVVVeeeerrrrssssiiiioooonnnn 11111111 ((((RRRReeeelllleeeeaaaasssseeee 6666....6666))))     XXXXLLLLooooaaaaddddFFFFoooonnnntttt((((3333XXXX11111111))))
  203.  
  204.  
  205.  
  206.                int ascent;              /* logical extent above baseline for spacing */
  207.                int descent;             /* logical decent below baseline for spacing */
  208.           } XFontStruct;
  209.  
  210.           X supports single byte/character, two bytes/character
  211.           matrix, and 16-bit character text operations.  Note that any
  212.           of these forms can be used with a font, but a single
  213.           byte/character text request can only specify a single byte
  214.           (that is, the first row of a 2-byte font).  You should view
  215.           2-byte fonts as a two-dimensional matrix of defined
  216.           characters: byte1 specifies the range of defined rows and
  217.           byte2 defines the range of defined columns of the font.
  218.           Single byte/character fonts have one row defined, and the
  219.           byte2 range specified in the structure defines a range of
  220.           characters.
  221.  
  222.           The bounding box of a character is defined by the
  223.           _X_C_h_a_r_S_t_r_u_c_t of that character.  When characters are absent
  224.           from a font, the default_char is used.  When fonts have all
  225.           characters of the same size, only the information in the
  226.           _X_F_o_n_t_S_t_r_u_c_t min and max bounds are used.
  227.  
  228.           The members of the _X_F_o_n_t_S_t_r_u_c_t have the following semantics:
  229.  
  230.           +o    The direction member can be either _F_o_n_t_L_e_f_t_T_o_R_i_g_h_t or
  231.                _F_o_n_t_R_i_g_h_t_T_o_L_e_f_t.  It is just a hint as to whether most
  232.                _X_C_h_a_r_S_t_r_u_c_t elements have a positive (_F_o_n_t_L_e_f_t_T_o_R_i_g_h_t)
  233.                or a negative (_F_o_n_t_R_i_g_h_t_T_o_L_e_f_t) character width metric.
  234.                The core protocol defines no support for vertical text.
  235.  
  236.           +o    If the min_byte1 and max_byte1 members are both zero,
  237.                min_char_or_byte2 specifies the linear character index
  238.                corresponding to the first element of the per_char
  239.                array, and max_char_or_byte2 specifies the linear
  240.                character index of the last element.
  241.  
  242.                If either min_byte1 or max_byte1 are nonzero, both
  243.                min_char_or_byte2 and max_char_or_byte2 are less than
  244.                256, and the 2-byte character index values
  245.                corresponding to the per_char array element N (counting
  246.                from 0) are:
  247.  
  248.  
  249.                     byte1 = N/D + min_byte1
  250.                     byte2 = N\D + min_char_or_byte2
  251.  
  252.  
  253.                where:
  254.  
  255.  
  256.                        D = max_char_or_byte2 - min_char_or_byte2 + 1
  257.                        / = integer division
  258.  
  259.  
  260.  
  261.      Page 4                                          (printed 10/3/02)
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.      XXXXLLLLooooaaaaddddFFFFoooonnnntttt((((3333XXXX11111111))))    XXXX VVVVeeeerrrrssssiiiioooonnnn 11111111 ((((RRRReeeelllleeeeaaaasssseeee 6666....6666))))     XXXXLLLLooooaaaaddddFFFFoooonnnntttt((((3333XXXX11111111))))
  269.  
  270.  
  271.  
  272.                        \ = integer modulus
  273.  
  274.           +o    If the per_char pointer is NULL, all glyphs between the
  275.                first and last character indexes inclusive have the
  276.                same information, as given by both min_bounds and
  277.                max_bounds.
  278.  
  279.           +o    If all_chars_exist is _T_r_u_e, all characters in the
  280.                per_char array have nonzero bounding boxes.
  281.  
  282.           +o    The default_char member specifies the character that
  283.                will be used when an undefined or nonexistent character
  284.                is printed. The default_char is a 16-bit character (not
  285.                a 2-byte character).  For a font using 2-byte matrix
  286.                format, the default_char has byte1 in the most-
  287.                significant byte and byte2 in the least significant
  288.                byte.  If the default_char itself specifies an
  289.                undefined or nonexistent character, no printing is
  290.                performed for an undefined or nonexistent character.
  291.  
  292.           +o    The min_bounds and max_bounds members contain the most
  293.                extreme values of each individual _X_C_h_a_r_S_t_r_u_c_t component
  294.                over all elements of this array (and ignore nonexistent
  295.                characters).  The bounding box of the font (the
  296.                smallest rectangle enclosing the shape obtained by
  297.                superimposing all of the characters at the same origin
  298.                [x,y]) has its upper-left coordinate at:
  299.                     [x + min_bounds.lbearing, y - max_bounds.ascent]
  300.  
  301.                Its width is:
  302.                     max_bounds.rbearing - min_bounds.lbearing
  303.  
  304.                Its height is:
  305.                     max_bounds.ascent + max_bounds.descent
  306.  
  307.           +o    The ascent member is the logical extent of the font
  308.                above the baseline that is used for determining line
  309.                spacing.  Specific characters may extend beyond this.
  310.  
  311.           +o    The descent member is the logical extent of the font at
  312.                or below the baseline that is used for determining line
  313.                spacing.  Specific characters may extend beyond this.
  314.  
  315.           +o    If the baseline is at Y-coordinate y, the logical
  316.                extent of the font is inclusive between the Y-
  317.                coordinate values (y - font.ascent) and (y +
  318.                font.descent - 1).  Typically, the minimum interline
  319.                spacing between rows of text is given by ascent +
  320.                descent.
  321.  
  322.           For a character origin at [x,y], the bounding box of a
  323.           character (that is, the smallest rectangle that encloses the
  324.  
  325.  
  326.  
  327.      Page 5                                          (printed 10/3/02)
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.      XXXXLLLLooooaaaaddddFFFFoooonnnntttt((((3333XXXX11111111))))    XXXX VVVVeeeerrrrssssiiiioooonnnn 11111111 ((((RRRReeeelllleeeeaaaasssseeee 6666....6666))))     XXXXLLLLooooaaaaddddFFFFoooonnnntttt((((3333XXXX11111111))))
  335.  
  336.  
  337.  
  338.           character's shape) described in terms of _X_C_h_a_r_S_t_r_u_c_t
  339.           components is a rectangle with its upper-left corner at:
  340.  
  341.           [x + lbearing, y - ascent]
  342.  
  343.           Its width is:
  344.  
  345.           rbearing - lbearing
  346.  
  347.           Its height is:
  348.  
  349.           ascent + descent
  350.  
  351.           The origin for the next character is defined to be:
  352.  
  353.           [x + width, y]
  354.  
  355.           The lbearing member defines the extent of the left edge of
  356.           the character ink from the origin.  The rbearing member
  357.           defines the extent of the right edge of the character ink
  358.           from the origin.  The ascent member defines the extent of
  359.           the top edge of the character ink from the origin.  The
  360.           descent member defines the extent of the bottom edge of the
  361.           character ink from the origin.  The width member defines the
  362.           logical width of the character.
  363.  
  364.      DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
  365.           _B_a_d_A_l_l_o_c  The server failed to allocate the requested
  366.                     resource or server memory.
  367.  
  368.           _B_a_d_F_o_n_t   A value for a Font or GContext argument does not
  369.                     name a defined Font.
  370.  
  371.           _B_a_d_N_a_m_e   A font or color of the specified name does not
  372.                     exist.
  373.  
  374.      SSSSEEEEEEEE AAAALLLLSSSSOOOO
  375.           XCreateGC(3X11), XListFonts(3X11), XSetFontPath(3X11)
  376.           _X_l_i_b - _C _L_a_n_g_u_a_g_e _X _I_n_t_e_r_f_a_c_e
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.      Page 6                                          (printed 10/3/02)
  394.  
  395.  
  396.  
  397.